<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<html>
	<%@include file="/common/fullFrame.jsp"%>
	<div id="registFormContainer">
		<form action="/etown/usermng/regist.action" method="post" id="registForm">
			<table width="100%">
				<tr>
					<td align="center" colspan="2" style="color: #009933;">
						填写信息-->邮件验证-->注册成功
					</td>
				</tr>
				<tr>
					<td align="center" colspan="2">
						<img class="hLine1"	src="images/u84.png" style="width: 800px;height: 2px;"/>
					</td>
				</tr>
				<tr></tr>
				<tr>
					<td width="45%" align="right">
						<label for="userName">
							<span class="required">用户名：</span>
						</label>
					</td>
					<td>
						<input id="userName" name=userName class="text" type="text"/>
					</td>
				</tr>
				<tr>
					<td width="45%" align="right">
						<label for="nickName">
							<span class="required">昵称：</span>
						</label>
					</td>
					<td>
						<input id="nickName" name=nickName class="text" type="text"/>
					</td>
				</tr>
				<tr>
					<td width="45%" align="right">
						<label for="password">
							<span class="required">密码：</span>
						</label>
					</td>
					<td>
						<input id="password" name="password" type="password" class="text"/>
					</td>
				</tr>
				<tr>
					<td width="45%" align="right">
						<label for="repassword">
							<span class="required">确认密码：</span>
						</label>
					</td>
					<td>
						<input id="repassword" name="repassword" type="password" class="text"/>
					</td>
				</tr>
				<tr>
					<td width="45%" align="right">
						<label for="email">
							<span class="required">EMail：</span>
						</label>
					</td>
					<td>
						<input id="email" name="email" type="text" class="text"/>
					</td>
				</tr>
				<tr>
					<td width="45%" align="right">
						<label for="blogTitle">
							<span class="required">博客标题：</span>
						</label>
					</td>
					<td>
						<input id="blogTitle" name="blogTitle" type="text" class="text"/>
					</td>
				</tr>
				<tr>
					<td align="center" colspan="2">
						<img class="hLine1"	src="images/u84.png" style="width: 800px;height: 2px;"/>
					</td>
				</tr>
				<tr></tr>
				<tr>
					<td width="45%" align="right">
						<label for="gender">
							<span>性别：</span>
						</label>
					</td>
					<td>
						<input name="gender" value="0" type="radio" checked="checked">男
						<input name="gender" value="1" type="radio">女
						<input name="gender" value="2" type="radio">其他
					</td>
				</tr>
				<tr>
					<td width="45%" align="right">
						<label for="industry">
							<span>所属行业：</span>
						</label>
					</td>
					<td>
						<select id="industry" name="industry">
						</select>
					</td>
				</tr>
				<tr>
					<td width="45%" align="right">
						<label for="from">
							<span>来自：</span>
						</label>
					</td>
					<td>
						<select id="country" name="country"></select>
						<select id="province" name="province"></select>
						<select id="city" name="city"></select>
					</td>
				</tr>
				<tr>
					<td align="center" colspan="2">
						<img class="hLine1"	src="images/u84.png" style="width: 800px;height: 2px;"/>
					</td>
				</tr>
				<tr></tr>
				<tr>
					<td align="center" colspan="2">
						<button id="toUserProtocal" type="button">
							查看用户条款
						</button>
						<button type="submit">
							同意并注册
						</button>
						<button id="toLoginBtn" type="button">
							返回登录页
						</button><br/>
					</td>
				</tr>
			</table>
		</form>
	</div>
	<link href="../css/regist.css" type="text/css" rel="stylesheet" />
	<script src="../common/jquery-validate/jquery.validate.js"	type="text/javascript"></script>
	<script src="../common/jquery-validate/localization/messages_cn.js"	type="text/javascript"></script>
	<script src="../common/cpcselector/CPCSelector.js"	type="text/javascript"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#registFormContainer input[type!='radio']").each(function(){
				$(this).width(150);
			});
			
			//userName只能是字母、数字、下划线
			$.validator.addMethod("userName", function(value, element) {   
			  	return this.optional(element) || /^\w+$/.test(value);   
			});
			
			//nickName可以是中文、字母、数字、下划线
			$.validator.addMethod("nickName", function(value, element) {   
			  	return this.optional(element) || /^[\u0391-\uFFE5\w]+$/.test(value);
			});
			
			//定义校验规则
			$("#registForm").validate({
				rules:{
					userName:{
						required:true,
						userName:true,
						minlength:4,
						maxlength:12,
						remote: {
						 	url: "/etown/validateUserId.action", 
						 	type: "post"
						}
					},
					nickName:{
						required:true,
						nickName:true,
						minlength:2,
						maxlength:16
					},
					password:{
						required:true,
						minlength:6,
						maxlength:16
					},
					repassword: {
				    	equalTo: "#password"   
				    },
					email: {   
				    	required:true,   
				    	email:true,
				    	minlength:10,
						maxlength:20,
						remote: {
						 	url: "/etown/validateEmail.action", 
						 	type: "post"
						}
				    }
				},
				messages: {
					userName:{
						userName:"只能是字母、数字、下划线"
					},
					nickName:{
						nickName:"可以是中文、字母、数字、下划线",
					},
				    repassword: {   
				   		required: "请填写确认密码",   
				    	equalTo: "两次密码输入不相同"   
				    }
				},
				focusInvalid:true,   
  				onkeyup:true  
			});
			
			//获取行业数据
			$.getJSON("/etown/getIndustry.action",function(data){
				var str="";
				$.each(data,function(index,info){
					str+="<option value="+info['dept_id']+">"+info['dept_name']+"</option>";
				});
				$("#industry").html(str);
			});
			
			//初始化省市数据
			var cv = CPCSelector.attach("country","province", "city");
			cv.initSelectedCodes("110000");
			
			//按钮跳转定义
			$("#toUserProtocal").click(function(){
				window.location.href="${pageContext.request.contextPath}/usermng/userProtocal.jsp";
			});
			
			$("#toLoginBtn").click(function(){
				window.location.href="${pageContext.request.contextPath}/usermng/login.jsp";
			});
		})
	</script>
</html>